<link rel="stylesheet" type="text/css" href="/Static/mobile/css/charge.css">

	<div class="content free-cash ">
		<div class="cashier-info-container center">
 
			<div class="avatar cashier-avatar">
				<img class="circular" src="<?php echo $memberinfo['headimgurl'];?>">
			</div>

			<div>
<p class="center  font-size-12" style="margin:0px 0px 15px 0px;">当前奖励佣金余额: <?php echo $memberinfo['prize_money'];?></p>
			
			</div>
			

			<div class="js-cashier-form block cashier-form text-left">
				<label for="cashier-price" class="font-size-12 cashier-label">金额（元）</label>
				<p class="cashier-field">
					<i class="money-text">¥</i><input id="cashier-price" type="number" class="cashier-text">
				</p>
			</div>
		</div>
		<div class="action-container" id="js-cashier-action">
			<div style="margin-bottom: 10px;">
				<button type="button" class="btn-pay btn btn-block btn-large btn-wxwappay  btn-green" onclick="paywechat();">立即充值</button>
			</div>
		</div>
		

		
		<div class="center action-tip js-cashier-tip">充值完成后，如需问题请联系客服</div>
	</div>
	
<script type="text/javascript">
function paywechat(){
	
	var money = $("#cashier-price").val();
	if(!checkCurrency(money)){
		showerror("充值金额有误");
		return false;
	}
	
	if(money<=0){
		showerror("充值金额必须大于0");
		return false;
	}
	
	$.ajax({
		url : '/mobile/charge/chargeajax',
		type : 'post',
		data : {'money':money,'uid':'<?php echo $memberinfo['uid'];?>'},
		dataType : 'json',
	//	async : false,
		success : function(data) {
			//关闭正在加载
			layer.closeAll();//关闭所有
			
			if(data.url){
				var urls = data.url;
			}else{
				var urls = '';
			}

			if(data.ret == 0){
				// 成功
				var order_id = data.url;
				jsApiCall(data.data,order_id)
				
			}else{
				// 失败
				showerror(data.msg,urls);
			}
		},
		beforeSend:function(){
			//正在加载
			layer.open({
		        type: 2,
		        shade: true,
		        shadeClose: false,
		    });
			
       },
       error: function() {
		   //关闭正在加载
    	   layer.closeAll();//关闭所有
		   showerror("网络错误,请重试");
       }
       
	});
}


function jsApiCall(jsparam,order_id)
{
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		jsparam,
		function(res){
			WeixinJSBridge.log(res.err_msg);
			 if(res.err_msg == "get_brand_wcpay_request:ok" ) {
			 
			   location.href = "/mobile/charge/payok/?order_id="+order_id;
			 
			 }else if(res.err_msg == "get_brand_wcpay_request:cancel"){
			 
				//alert("未支付成功,请重试");
			 }
			//alert(res.err_msg);

		}
	);
}
</script>
<include file="Common:nav" />